package org.gap.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */
@IdClass(org.gap.domain.CodesPostauxPK.class)
@Entity
@NamedQueries({
		@NamedQuery(name = "findAllCodesPostauxs", query = "select myCodesPostaux from CodesPostaux myCodesPostaux"),
		@NamedQuery(name = "findCodesPostauxByCdpBureauDistributeur", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpBureauDistributeur = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpBureauDistributeurContaining", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpBureauDistributeur like ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpCodeMiseAJour", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpCodeMiseAJour = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpCodeMiseAJourContaining", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpCodeMiseAJour like ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpCodePostal", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpCodePostal = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpCodePostalContaining", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpCodePostal like ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpLocalite", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpLocalite = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpLocaliteContaining", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpLocalite like ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpLocaliteFiscalStandard", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpLocaliteFiscalStandard = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpNInsee", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpNInsee = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpNInseeContaining", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpNInsee like ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpParticuBureauDistrib", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpParticuBureauDistrib = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpParticuBureauDistribContaining", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpParticuBureauDistrib like ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpParticuCommuneLieuDit", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpParticuCommuneLieuDit = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpParticuCommuneLieuDitContaining", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpParticuCommuneLieuDit like ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpPays", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpPays = ?1"),
		@NamedQuery(name = "findCodesPostauxByCdpPaysContaining", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpPays like ?1"),
		@NamedQuery(name = "findCodesPostauxByPrimaryKey", query = "select myCodesPostaux from CodesPostaux myCodesPostaux where myCodesPostaux.cdpPays = ?1 and myCodesPostaux.cdpCodePostal = ?2 and myCodesPostaux.cdpNInsee = ?3 and myCodesPostaux.cdpLocalite = ?4") })
@Table(schema = "GAP", name = "CODES_POSTAUX")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "GAP_v2/org/gap/domain", name = "CodesPostaux")
@XmlRootElement(namespace = "GAP_v2/org/gap/domain")
public class CodesPostaux implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "CDP_PAYS", length = 3, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String cdpPays;
	/**
	 */

	@Column(name = "CDP_CODE_POSTAL", length = 12, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String cdpCodePostal;
	/**
	 */

	@Column(name = "CDP_N_INSEE", length = 5, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String cdpNInsee;
	/**
	 */

	@Column(name = "CDP_LOCALITE", length = 32, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	String cdpLocalite;
	/**
	 */

	@Column(name = "CDP_BUREAU_DISTRIBUTEUR", length = 32, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String cdpBureauDistributeur;
	/**
	 */

	@Column(name = "CDP_PARTICU_COMMUNE_LIEU_DIT", length = 1, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String cdpParticuCommuneLieuDit;
	/**
	 */

	@Column(name = "CDP_PARTICU_BUREAU_DISTRIB", length = 1, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String cdpParticuBureauDistrib;
	/**
	 */

	@Column(name = "CDP_CODE_MISE_A_JOUR", length = 1, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String cdpCodeMiseAJour;
	/**
	 */

	@Column(name = "CDP_LOCALITE_FISCAL_STANDARD", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Boolean cdpLocaliteFiscalStandard;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "CDP_PAYS", referencedColumnName = "PPP_PAYS", nullable = false, insertable = false, updatable = false) })
	@XmlTransient
	Pays pays;
	/**
	 */
	@OneToMany(mappedBy = "codesPostaux", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<org.gap.domain.Adresses> adresseses;

	/**
	 */
	public void setCdpPays(String cdpPays) {
		this.cdpPays = cdpPays;
	}

	/**
	 */
	public String getCdpPays() {
		return this.cdpPays;
	}

	/**
	 */
	public void setCdpCodePostal(String cdpCodePostal) {
		this.cdpCodePostal = cdpCodePostal;
	}

	/**
	 */
	public String getCdpCodePostal() {
		return this.cdpCodePostal;
	}

	/**
	 */
	public void setCdpNInsee(String cdpNInsee) {
		this.cdpNInsee = cdpNInsee;
	}

	/**
	 */
	public String getCdpNInsee() {
		return this.cdpNInsee;
	}

	/**
	 */
	public void setCdpLocalite(String cdpLocalite) {
		this.cdpLocalite = cdpLocalite;
	}

	/**
	 */
	public String getCdpLocalite() {
		return this.cdpLocalite;
	}

	/**
	 */
	public void setCdpBureauDistributeur(String cdpBureauDistributeur) {
		this.cdpBureauDistributeur = cdpBureauDistributeur;
	}

	/**
	 */
	public String getCdpBureauDistributeur() {
		return this.cdpBureauDistributeur;
	}

	/**
	 */
	public void setCdpParticuCommuneLieuDit(String cdpParticuCommuneLieuDit) {
		this.cdpParticuCommuneLieuDit = cdpParticuCommuneLieuDit;
	}

	/**
	 */
	public String getCdpParticuCommuneLieuDit() {
		return this.cdpParticuCommuneLieuDit;
	}

	/**
	 */
	public void setCdpParticuBureauDistrib(String cdpParticuBureauDistrib) {
		this.cdpParticuBureauDistrib = cdpParticuBureauDistrib;
	}

	/**
	 */
	public String getCdpParticuBureauDistrib() {
		return this.cdpParticuBureauDistrib;
	}

	/**
	 */
	public void setCdpCodeMiseAJour(String cdpCodeMiseAJour) {
		this.cdpCodeMiseAJour = cdpCodeMiseAJour;
	}

	/**
	 */
	public String getCdpCodeMiseAJour() {
		return this.cdpCodeMiseAJour;
	}

	/**
	 */
	public void setCdpLocaliteFiscalStandard(Boolean cdpLocaliteFiscalStandard) {
		this.cdpLocaliteFiscalStandard = cdpLocaliteFiscalStandard;
	}

	/**
	 */
	public Boolean getCdpLocaliteFiscalStandard() {
		return this.cdpLocaliteFiscalStandard;
	}

	/**
	 */
	public void setPays(Pays pays) {
		this.pays = pays;
	}

	/**
	 */
	public Pays getPays() {
		return pays;
	}

	/**
	 */
	public void setAdresseses(Set<Adresses> adresseses) {
		this.adresseses = adresseses;
	}

	/**
	 */
	public Set<Adresses> getAdresseses() {
		if (adresseses == null) {
			adresseses = new java.util.LinkedHashSet<org.gap.domain.Adresses>();
		}
		return adresseses;
	}

	/**
	 */
	public CodesPostaux() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(CodesPostaux that) {
		setCdpPays(that.getCdpPays());
		setCdpCodePostal(that.getCdpCodePostal());
		setCdpNInsee(that.getCdpNInsee());
		setCdpLocalite(that.getCdpLocalite());
		setCdpBureauDistributeur(that.getCdpBureauDistributeur());
		setCdpParticuCommuneLieuDit(that.getCdpParticuCommuneLieuDit());
		setCdpParticuBureauDistrib(that.getCdpParticuBureauDistrib());
		setCdpCodeMiseAJour(that.getCdpCodeMiseAJour());
		setCdpLocaliteFiscalStandard(that.getCdpLocaliteFiscalStandard());
		setPays(that.getPays());
		setAdresseses(new java.util.LinkedHashSet<org.gap.domain.Adresses>(that.getAdresseses()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("cdpPays=[").append(cdpPays).append("] ");
		buffer.append("cdpCodePostal=[").append(cdpCodePostal).append("] ");
		buffer.append("cdpNInsee=[").append(cdpNInsee).append("] ");
		buffer.append("cdpLocalite=[").append(cdpLocalite).append("] ");
		buffer.append("cdpBureauDistributeur=[").append(cdpBureauDistributeur).append("] ");
		buffer.append("cdpParticuCommuneLieuDit=[").append(cdpParticuCommuneLieuDit).append("] ");
		buffer.append("cdpParticuBureauDistrib=[").append(cdpParticuBureauDistrib).append("] ");
		buffer.append("cdpCodeMiseAJour=[").append(cdpCodeMiseAJour).append("] ");
		buffer.append("cdpLocaliteFiscalStandard=[").append(cdpLocaliteFiscalStandard).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((cdpPays == null) ? 0 : cdpPays.hashCode()));
		result = (int) (prime * result + ((cdpCodePostal == null) ? 0 : cdpCodePostal.hashCode()));
		result = (int) (prime * result + ((cdpNInsee == null) ? 0 : cdpNInsee.hashCode()));
		result = (int) (prime * result + ((cdpLocalite == null) ? 0 : cdpLocalite.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof CodesPostaux))
			return false;
		CodesPostaux equalCheck = (CodesPostaux) obj;
		if ((cdpPays == null && equalCheck.cdpPays != null) || (cdpPays != null && equalCheck.cdpPays == null))
			return false;
		if (cdpPays != null && !cdpPays.equals(equalCheck.cdpPays))
			return false;
		if ((cdpCodePostal == null && equalCheck.cdpCodePostal != null) || (cdpCodePostal != null && equalCheck.cdpCodePostal == null))
			return false;
		if (cdpCodePostal != null && !cdpCodePostal.equals(equalCheck.cdpCodePostal))
			return false;
		if ((cdpNInsee == null && equalCheck.cdpNInsee != null) || (cdpNInsee != null && equalCheck.cdpNInsee == null))
			return false;
		if (cdpNInsee != null && !cdpNInsee.equals(equalCheck.cdpNInsee))
			return false;
		if ((cdpLocalite == null && equalCheck.cdpLocalite != null) || (cdpLocalite != null && equalCheck.cdpLocalite == null))
			return false;
		if (cdpLocalite != null && !cdpLocalite.equals(equalCheck.cdpLocalite))
			return false;
		return true;
	}
}
